package top.itlir.edc.service.impl;

import java.util.Date;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import top.itlir.edc.dao.OrderRepository;
import top.itlir.edc.domain.Area;
import top.itlir.edc.domain.Order;
import top.itlir.edc.service.IOrderService;

@Service
@Transactional
public class OrderServiceImpl implements IOrderService {

	@Autowired
	private OrderRepository orderRepository;

	@Override
	public void saveOrder(Order order) {
		// 订单号 uuid
		order.setOrderNum(UUID.randomUUID().toString());
		// 订单时间 new Date
		order.setOrderTime(new Date());
		// 解决瞬时态问题
		Area recArea = order.getRecArea();
		Area sendArea = order.getSendArea();
		
		order.setRecArea(null);
		order.setSendArea(null);
		orderRepository.save(order);
	}
	
}
